<?php




// 处理引号，HTML标签引起的输入框显示错误，过滤字符型变量
$process_include    = array('rolename', 'description');
string_pre_process($record, $process_include);
$back_url   = strcode(getcookie('back_url'), 'DECODE');
if($back_url == '') $back_url   = $mod_url['li'];

$txt_form_title = $GLOBALS['_MODULES'][$mod]['actions'][$action]['name'];






require($abs_admin_cppath . '/header.php');
?>
<SCRIPT LANGUAGE="JavaScript" SRC="<?php echo $url_global['common']; ?>/js/Validator.js"></SCRIPT>


		<div class="datacontainer2" style="width:700px;">
<div class="header">
	<?php echo $txt_form_title; ?>
</div>
<table BORDER="0" cellpadding="0" cellspacing="0" width="100%" class="list_table">
<form action="<?php echo $mod_url['save']; ?>" method="post" name="item_data" onsubmit="return Validator.Validate(this,3)">
<TR>
	<TD class="cell">
		以下是用户【<?php echo $record['username']; ?>】能管理的文章
	</TD>
</TR>
<TR>
	<TD class="cell">
<SCRIPT LANGUAGE="JavaScript">
<!--
function prase_cclass(o) {
    // nsid
    // npid

    var nsid = o.nsid;
    var npid = o.npid;


    if(nsid != '') {
        var arr_nsid = nsid.split(',');
        for(i=0;i<arr_nsid.length;i++) {
            o1 = document.getElementById('cid_' + arr_nsid[i]);
            if(o1 != null && typeof(o1) == 'object') {
                o1.checked = o.checked;
            }
        }
    }


    if(!o.checked) {
        // 如果当前为不选择，则上级也不能选择

        // 检查同级是否有选择的，如果没有选择则取消上级
        var nsaid = o.nsaid;
        var ischk = false;
        if(nsaid != '') {
            var arr_nsaid = nsaid.split(',');
            for(i=0;i<arr_nsaid.length;i++) {
                o1 = document.getElementById('cid_' + arr_nsaid[i]);
                if(o1 != null && typeof(o1) == 'object' && o1.checked) {
                    ischk = true;
                    break;
                }
            }
        }
        if(ischk == false) {
            // 取消直接上级的选择
            // pid
            cancel_pnode(o.pid);
        }
    }
}

function cancel_pnode(pid) {
    var o = document.getElementById('cid_' + pid);
    o.checked = false;
    // 判断父id的同级是否有
    var nsaid = o.nsaid;
    var ischk = false;
    if(nsaid != '') {
        var arr_nsaid = nsaid.split(',');
        for(i=0;i<arr_nsaid.length;i++) {
            o1 = document.getElementById('cid_' + arr_nsaid[i]);
            if(o1 != null && typeof(o1) == 'object' && o1.checked) {
                ischk = true;
                break;
            }
        }
    }



    if(ischk == false) {
        if(o.pid > 0) {
            cancel_pnode(o.pid);
        }
    }
}
//-->
</SCRIPT>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<?php
foreach($$class_var as $c) {
    $node_pre   = tree_node_htmlpre($c['__node_pre'], 1);


    $node_path_id   = '';
    foreach($c['__node_path'] as $np) {
        $node_path_id  .= $np['__id__'] . ',';
    }
    if($node_path_id != '') {
        $node_path_id = substr($node_path_id, 0, (strlen($node_path_id)-1));
    }
    $node_sub_id    = find_subnode_id($c['__id__'], $GLOBALS[$class_var]);
    $node_same_id   = find_samelevel_id($c['__parent_id__'], $GLOBALS[$class_var]);
    $node_pid       = $c['__parent_id__'];



    $find = false;
    foreach($record['rightcid'] as $rcid) {
        if(@(int)$rcid == @(int)$c['__id__']) {
            $find = true;
            break;
        }
    }
    $checked = '';
    if($find) {
        $checked = 'checked';
    }
?>
<TR>
    <TD><?php echo $node_pre; ?>
        <INPUT TYPE="checkbox" NAME="cclass[cid][]" ID="cid_<?php echo $c['__id__']; ?>" value="<?php echo $c['__id__']; ?>" npid="<?php echo $node_path_id; ?>" nsid="<?php echo $node_sub_id; ?>" nsaid="<?php echo $node_same_id; ?>" pid="<?php echo $node_pid; ?>" <?php echo $checked; ?> onclick="return prase_cclass(this);">
        <label for="cid_<?php echo $c['__id__']; ?>"><?php echo $c['__text__']; ?></label>
    </TD>
</TR>
<?php
}
?>
</TABLE>
	</TD>
</TR>
<TR>
	<TD class="submit">
		<input type="submit" value=" 保存 " class="button02">
		<input type="reset" value=" 重置 " class="button02">
		<input type="button" value=" 返回 " class="button02" onclick="location.href='<?php echo $back_url; ?>'">
		<input type="hidden" name="back_url" value="<?php echo $back_url; ?>">
		<input type="hidden" name="cclass[uid]" value="<?php echo $record['uid']; ?>">
		<input type="hidden" name="save" value="<?php echo $save_flag; ?>">
	</TD>
</TR>
</form>
</TABLE>

		</div>


<?php
require($abs_admin_cppath . '/footer.php');
?>